/*
 *   Copyright 1999-2016 Asiainfo Technologies(China),Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */

package com.asiainfo.redis.web.controller;

import com.asiainfo.redis.entity.Result;
import com.asiainfo.redis.service.ScheduleService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @version v 1.0 on 2016/8/10 13:58
 * @auther william.xu
 */
@RestController
@RequestMapping("/schedule")
public class ScheduleController extends BaseController{

    @Resource
    private ScheduleService scheduleService;

    @RequestMapping("/getClusterBusiTypeList")
    public Result getClusterBusiTypeList(){
        Result result = new Result();
        result.setResult(scheduleService.getClusterBusiTypeList());
        return result;

    }

    @RequestMapping("/setRefreshChangeBusiDataCronExpression")
    public Result setRefreshChangeBusiDataCronExpression(String cronExpression) throws Exception{
        Result result = new Result();
        scheduleService.setRefreshChangeBusiDataCronExpression(cronExpression);
        return result;
    }

    @RequestMapping("/getRefreshChangeBusiDataCronExpression")
    public Result getRefreshChangeBusiDataCronExpression() throws Exception{
        Result result = new Result();
        result.setResult(scheduleService.getRefreshChangeBusiDataCronExpression());
        return result;
    }

    @RequestMapping("/setRefreshAllBusiDataCronExpression")
    public Result setRefreshAllBusiDataCronExpression(Long clusterBusiTypeRefId, String cronExpression) throws
            Exception{
        Result result = new Result();
        scheduleService.setRefreshAllBusiDataCronExpression(clusterBusiTypeRefId, cronExpression);
        return result;
    }

    @RequestMapping("/getRefreshAllBusiDataCronExpression")
    public Result getRefreshAllBusiDataCronExpression(Long clusterBusiTypeRefId) throws Exception{
        Result result = new Result();
        result.setResult(scheduleService.getRefreshAllBusiDataCronExpression(clusterBusiTypeRefId));
        return result;
    }

    @RequestMapping("/refreshAllData")
    public Result refreshAllData(Long clusterBusiTypeRefId) throws Exception{
        Result result = new Result();
        scheduleService.refreshAllData(clusterBusiTypeRefId);
        return result;
    }


}
